<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('base');
pc_base::load_sys_class('poll');


class index extends base {
	private $db;
	function __construct() {
        pc_base::load_app_func('global');
        $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid();
        define("SITEID",$siteid);
        $this->db = pc_base::load_model('course_model');
        $this->company_db = pc_base::load_model('company_model');
	}
	
	/**
	 *课程介绍
	 */
	public function course_list(){
		$html_title = '培训入口';
		//获取机构
		$company_where = "";
		$company_where .= "status = 1 AND siteid =".SITEID;
		$company_info = $this->company_db->listinfo($where);
		//获取课程
		$where = "";
		$where .= "status = 0 AND site =".SITEID;
		$course_info = $this->db->listinfo($where,'id DESC',1,5);
		include template('course','course_list');
	}
	
	/**
	 *ajax获取课程列表
	 */
	public function ajax_course() {
		$where = "";
		$where .= "status = 0 AND site =".SITEID;
		$page = isset($_POST['page']) ? intval($_POST['page']) : 1; 
		$ajax_course = $this->db->listinfo($where,'id DESC',$page,5);
		if ($page == 1) {
			return '';
		} else {
			echo json_encode($ajax_course);
		}
	}
	
	/**
	* 机构详情
	* @date: 2016年12月29日 上午10:58:52
	* @author: ASUS
	*/
	public function show() {
		$html_title = "机构详情";
		$where = '';
		$where .= "id = ".$_GET['id'];
		if (isset($_GET['id']) && !empty($_GET['id'])) {
			$result = $this->company_db->get_one($where);
			var_dump($result);
			include template('course','show');
		} else {
			echo '资源不存在';
		}
	}
	
	/**
	* 课程详情
	* @date: 2016年12月29日 上午10:46:24
	* @author: ASUS
	*/
	public function course_detail() {
		$html_title = "课程详情";
		$where = '';
		$where .= "id = ".$_GET['id'];
		if (isset($_GET['id']) && !empty($_GET['id'])) {
			$result = $this->db->get_one($where);
			var_dump($result);
			include template('course','course_detail');
		} else {
			echo '资源不存在';
		}
		
	}
}